import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.config.productionTip = false

Vue.use(ElementUI);



//注册api插件
import {getRequest} from "./utils/api";
import {postKeyValueRequest} from "./utils/api";
import {putRequest} from "./utils/api";
import {deleteRequest} from "./utils/api";
import {postRequest} from "./utils/api";

Vue.prototype.getRequest=getRequest;
Vue.prototype.postKeyValueRequest=postKeyValueRequest;
Vue.prototype.putRequest=putRequest;
Vue.prototype.deleteRequest=deleteRequest;
Vue.prototype.postRequest=postRequest;

import {Message} from "element-ui";

//路由导航解决直接跳路径
router.beforeEach((to, from, next) => {//to是去那个路径，from是来自那的路径，next()放行的意思
                                                //相当于过滤器的doFilter()
   if(to.path =='/'){
       window.document.body.style.background='ghostwhite';
       next();
   }
   // if(to.path =='/home')
    else {
       window.document.body.style.background='honeydew';
       let s=window.sessionStorage.getItem("loginU");
       if(s==null){
          Message.warning('请先登录');
          next('/');
       }
       else {
           next();
       }
    }

})

import echarts from 'echarts'
Vue.prototype.$echarts=echarts;

import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
// use
Vue.use(mavonEditor)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
//入口js文件